# encoding: UTF-8
'''
Created on 2013年10月31日

@author: xuben

整点在线奖励
'''

from ..common import Command, RequestModel, Logger
from ..common.SocketService import gameSocketService
from ..role import RoleData

class OnlineRewardGetInfoRequest(RequestModel.RequestModel):
    '''
    classdocs
    '''
    
    def setCommand(self):
        self.command = Command.GET_ONLINE_REWARD_INFO
        
    def onReceive(self, data):
        if 'number' in data:
            RoleData.onlineRewardNum = data['number']
            
'''
领取整点在线奖励
'''
def getOnlineReward():
    command = Command.GET_ONLINE_REWARD
    params = ''
    gameSocketService.send(command, params, getOnlineRewardCallback)
    
'''
领取整点在线奖励回调函数
'''
def getOnlineRewardCallback(data):
    if 'rewardType' in data and 'rewardNum' in data:
        Logger.log('领取整点在线奖励, type:' + str(data['rewardType']) + ', num:' + str(data['rewardNum']), output = True)
    if 'number' in data:
        RoleData.onlineRewardNum = data['number']